'// ========================================================================= '
'// ------------------------------------------------------------------------- '
'//!				\file		CApp.vb
'			        \date		june 2010
'			        \author		TNick
'
'			        \brief		
'
'
'   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'   This file is considered universal knowledge. No restrictions
'   are imposed; use as you see fit.
'   Please read ReadMe.txt and Licence.txt in root folder
'   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'
'   The code here implements general application code such as initialization
'   and termination
'// ------------------------------------------------------------------------- '
'// ========================================================================= '
'//
'//
'//
'//
'//  IMPORTS     ------------------------------------------------------------ '
#Region "Imports"

Imports System
Imports Microsoft.Win32
Imports System.Reflection

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.DatabaseServices
'Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Customization
'Imports Autodesk.AutoCAD.Colors
'Imports Autodesk.AutoCAD.GraphicsSystem

#End Region
'//  IMPORTS     ============================================================ '
'//
'//
'//
'//
'//  DEFINITIONS    --------------------------------------------------------- '
<Assembly: ExtensionApplication(GetType(CApp))> 
<Assembly: CommandClass(GetType(CApp))> 

'// Module id for each part
Public Enum MIDS
    GRID  = 0   '// CM_Grid
    FSK_PT3D    '// CM_3DPoints
    DIMS        '// CM_Dims
    IMGDB       '// CM_ImageDb
    POLYA       '// CM_PolyArea
    SIMB        '// CM_Symbols
    TABLE       '// CM_Table
    SURV1       '// CM_Survey1
    POLY        '// CM_Polyline

#If RO_SPECIFICS = True Then
    RO_TABLE    '// CM_RO_Tables
#End If

    COUNT
End Enum

'//  DEFINITIONS    ========================================================= '
'//
'//
'//
'//
'//  DATA    ---------------------------------------------------------------- '


'//  DATA    ================================================================ '
'//
'//
'//
'//
'//  CLASS    --------------------------------------------------------------- '
Public Class CApp

#Region "Implementation"
    Implements Autodesk.AutoCAD.Runtime.IExtensionApplication
#End Region

    '// --------------------------------------------------------------------- '
    '// DATA

    #Region "Public variables"
        '// Global variable that tells where this module is located
	    Public Shared sAppPath As String
        '// the registry key used by this application
	    Public Shared regAppAddInKey As RegistryKey
        '// the registry key used by this application
	    Public Const sTHISAPPNAME As String = "FieldSK_V1"
	    '// plain old quote
        Public Const QUOTE As String = """"


        Private Const sCMD_SETTINGS As String = "FSK"
    #End Region

    '// module pointer for each one that is running
    Public Shared mi_Grid As CM_Grid
    Public Shared mi_3DPoints As CM_3DPoints
    Public Shared mi_Dims As CM_Dims
    Public Shared mi_ImageDb As CM_ImageDb
    Public Shared mi_PolyArea As CM_PolyArea
    Public Shared mi_Symbols As CM_Symbols
    Public Shared mi_Table As CM_Table
    Public Shared mi_Surv1 As CM_Survey1
    Public Shared mi_Polyline As CM_Polyline
#If RO_SPECIFICS = True Then
    Public Shared mi_RoTables As CM_RO_Tables
#End If

    '// each value holds either "" for unload state or "1" for load state
    Public Shared MLoadState(MIDS.COUNT) As Char

    '// has the instance of class only durring Autoinstallation
    #If HARDCORE_CUI
    Public Shared cuiCl As CCuiF
    #End If


    '// ===================================================================== '



#Region "Required by IExtensionApplication"


    '// --------------------------------------------------------------------- '
    '// called as the application is loading
    Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize



		' Get the location of this module
		Dim sAssemblyPath As String = Assembly.GetExecutingAssembly().Location
        sAppPath = _
            sAssemblyPath.Substring(0, sAssemblyPath.LastIndexOf("\") + 1)
        ' part of update
        If (System.IO.File.Exists(sAppPath & "Update\FSK_Updater.dll"))
            Try
                If (System.IO.File.Exists(sAppPath & "FSK_Updater.dll")) Then
                    System.IO.File.Delete(sAppPath & "FSK_Updater.dll")
                End If
                System.IO.File.Move(sAppPath & "Update\FSK_Updater.dll", _
                                    sAppPath & "FSK_Updater.dll")
            Catch ex As System.Exception
                Debug.Print("FSK: Failed to update FSK_Updater.dll")
            End Try
        End If

        '// see if log file has got bigger than limit
        If (System.IO.File.Exists(CApp.sAppPath & CMain.APPLOG)) Then

            Dim MyFile As New IO.FileInfo(CApp.sAppPath & CMain.APPLOG)
            If MyFile.Length > 1024*1024*4 Then
                MyFile = Nothing
                System.IO.File.Delete(CApp.sAppPath & CMain.APPLOG)
            End If
            MyFile = Nothing
        End If


        RegisterMyApp()
        
        BuildMenuCUI()
            
        CSett.Init()
        
        CM_Grid.DoPrereq()
        CM_3DPoints.DoPrereq()
        CM_Dims.DoPrereq()
        CM_PolyArea.DoPrereq()
        CM_ImageDb.DoPrereq()
        CM_Symbols.DoPrereq()
        CM_Table.DoPrereq()
        CM_Survey1.DoPrereq()
        CM_Polyline.DoPrereq()
#If RO_SPECIFICS = True Then
        CM_RO_Tables.DoPrereq()
#End If

        MLoadState(MIDS.GRID) = CChar("")
        if CSett.GetBolStg("Main","GRID_Load",True) then
            mi_Grid = New CM_Grid()
            MLoadState(MIDS.GRID) = CChar("1")
        End if

        MLoadState(MIDS.FSK_PT3D) = CChar("")
        if CSett.GetBolStg("Main","PT3D_Load",True) then
            mi_3DPoints = New CM_3DPoints()
            MLoadState(MIDS.FSK_PT3D) = CChar("1")
        End if

        MLoadState(MIDS.DIMS) = CChar("")
        if CSett.GetBolStg("Main","DIMS_Load",True) then
            mi_Dims = New CM_Dims()
            MLoadState(MIDS.DIMS) = CChar("1")
        End if

        MLoadState(MIDS.IMGDB) = CChar("")
        if CSett.GetBolStg("Main","IMGDB_Load",True) then
            mi_ImageDb = New CM_ImageDb()
            MLoadState(MIDS.IMGDB) = CChar("1")
        End if

        MLoadState(MIDS.POLYA) = CChar("")
        if CSett.GetBolStg("Main","POLYA_Load",True) then
            mi_PolyArea = New CM_PolyArea()
            MLoadState(MIDS.POLYA) = CChar("1")
        End if

        MLoadState(MIDS.SIMB) = CChar("")
        if CSett.GetBolStg("Main","SIMB_Load",True) then
            mi_Symbols = New CM_Symbols()
            MLoadState(MIDS.SIMB) = CChar("1")
        End if

        MLoadState(MIDS.TABLE) = CChar("")
        if CSett.GetBolStg("Main","TABL_Load",True) then
            mi_Table = New CM_Table()
            MLoadState(MIDS.TABLE) = CChar("1")
        End If

        MLoadState(MIDS.SURV1) = CChar("")
        If CSett.GetBolStg("Main", "SURV1_Load", True) Then
            mi_Surv1 = New CM_Survey1()
            MLoadState(MIDS.SURV1) = CChar("1")
        End If

        MLoadState(MIDS.POLY) = CChar("")
        If CSett.GetBolStg("Main", "POLY_Load", True) Then
            mi_Polyline = New CM_Polyline()
            MLoadState(MIDS.POLY) = CChar("1")
        End If

#If RO_SPECIFICS = True Then
        MLoadState(MIDS.RO_TABLE) = CChar("")
        If CSett.GetBolStg("Main", "RO_TABL_Load", True) Then
            mi_RoTables = New CM_RO_Tables()
            MLoadState(MIDS.RO_TABLE) = CChar("1")
        End If
#End If


        CMain.bAlertType = DirectCast( _
            CSett.GetIntStg("Main", "ALERTTY", CMain.ALERTTY.MSGB),  _
            CMain.ALERTTY)
        CMain.bInformType = DirectCast( _
            CSett.GetIntStg("Main","INFORMTY",CMain.INFORMTY.PROMPT), _
            CMain.INFORMTY)
        CMain.eAppLang = DirectCast( _
            CSett.GetIntStg("Main","LANG",CMain.ELANG.EN), _
            CMain.ELANG)
        CMain.eAppDbg = DirectCast( _
            CSett.GetIntStg("Main","DEBUGMODE",CMain.EDEBUG.DBGPRINT), _
            CMain.EDEBUG)


        Debug.Print("FieldSK loaded" & vbCrLf)
        GC.Collect()
        GC.WaitForPendingFinalizers()
    End Sub
    '// ===================================================================== '

    '// --------------------------------------------------------------------- '
    '// called as the application is unloading
    Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate

        '// save the state of each module
        If (mi_Grid IS Nothing) then
            CSett.SaveStg("Main","GRID_Load",FALSE)
        Else
            mi_Grid.Terminate()
            CSett.SaveStg("Main","GRID_Load",TRUE)
        End If
        If (mi_3DPoints IS Nothing) then
            CSett.SaveStg("Main","PT3D_Load",FALSE)
        Else
            mi_3DPoints.Terminate()
            CSett.SaveStg("Main","PT3D_Load",TRUE)
        End If
        If (mi_Dims IS Nothing) then
            CSett.SaveStg("Main","DIMS_Load",FALSE)
        Else
            mi_Dims.Terminate()
            CSett.SaveStg("Main","DIMS_Load",TRUE)
        End If
        If (mi_ImageDb IS Nothing) then
            CSett.SaveStg("Main","IMGDB_Load",FALSE)
        Else
            mi_ImageDb.Terminate()
           CSett.SaveStg("Main","IMGDB_Load",TRUE)
        End If
        If (mi_PolyArea IS Nothing) then
            CSett.SaveStg("Main","POLYA_Load",FALSE)
        Else
            mi_PolyArea.Terminate()
            CSett.SaveStg("Main","POLYA_Load",TRUE)
        End If
        If (mi_Symbols IS Nothing) then
            CSett.SaveStg("Main","SIMB_Load",FALSE)
        Else
            mi_Symbols.Terminate()
            CSett.SaveStg("Main","SIMB_Load",TRUE)
        End If
        If (mi_Table IS Nothing) then
            CSett.SaveStg("Main","TABL_Load",FALSE)
        Else
            mi_Symbols.Terminate()
            CSett.SaveStg("Main","TABL_Load",TRUE)
        End If
        If (mi_Surv1 Is Nothing) Then
            CSett.SaveStg("Main", "SURV1_Load", False)
        Else
            mi_Surv1.Terminate()
            CSett.SaveStg("Main", "SURV1_Load", True)
        End If
        If (mi_Polyline Is Nothing) Then
            CSett.SaveStg("Main", "POLY_Load", False)
        Else
            mi_Polyline.Terminate()
            CSett.SaveStg("Main", "POLY_Load", True)
        End If

#If RO_SPECIFICS = True Then
        If (mi_RoTables Is Nothing) Then
            CSett.SaveStg("Main", "RO_TABL_Load", False)
        Else
            mi_RoTables.Terminate()
            CSett.SaveStg("Main", "RO_TABL_Load", True)
        End If
#End If


        CSett.SaveStg("Main","ALERTTY",CInt(CMain.bAlertType))
        CSett.SaveStg("Main","INFORMTY",CInt(CMain.bInformType))
        CSett.SaveStg("Main","LANG",CInt(CMain.eAppLang))
        CSett.SaveStg("Main","DEBUGMODE",CInt(CMain.eAppDbg))

        'UnregisterMyApp()
        GC.Collect()
        GC.WaitForPendingFinalizers()
    End Sub
    '// ===================================================================== '

#End Region

#Region " --      Register - Unregister"

    Private Shared Sub RegisterMyApp()
        Dim regAcadProdKey As RegistryKey = Nothing
        Dim regAcadAppKey As RegistryKey = Nothing
        Try
            ' Get the AutoCAD Applications key
            Dim sProdKey As String = HostApplicationServices.Current.RegistryProductRootKey

            regAcadProdKey = Registry.CurrentUser.OpenSubKey(sProdKey)
            regAcadAppKey = regAcadProdKey.OpenSubKey("Applications", True)

            ' Check to see if the "MyApp" key exists
            Dim subKeys() As String = regAcadAppKey.GetSubKeyNames()
            For Each sSubKey As String In subKeys
                '' If the application is already registered, exit
                If (sSubKey.Equals(sTHISAPPNAME)) Then
                    regAppAddInKey = regAcadAppKey.OpenSubKey(sTHISAPPNAME, True)


                    '// get current settings (will go to default if not present)
                    Dim aObj As Object = _
                    regAppAddInKey.GetValue("ALERTTY", Nothing)
                    If aObj Is Nothing Then
                        CMain.bAlertType = CMain.ALERTTY.MSGB
                    Else
                        CMain.bAlertType = DirectCast(aObj, CMain.ALERTTY)
                    End If

                    aObj = regAppAddInKey.GetValue("LANG", Nothing)
                    If aObj Is Nothing Then
                        CMain.eAppLang = CMain.ELANG.EN
                    Else
                        CMain.eAppLang = DirectCast(aObj, CMain.ELANG)
                    End If

                    GoTo SubKeyOK
                End If
            Next

            ' Get the location of this module
            Dim sAssemblyPath As String = Assembly.GetExecutingAssembly().Location

            ' Register the application
            regAppAddInKey = regAcadAppKey.CreateSubKey(sTHISAPPNAME)
            regAppAddInKey.SetValue("DESCRIPTION", sTHISAPPNAME, RegistryValueKind.String)
            regAppAddInKey.SetValue("LOADCTRLS", 14, RegistryValueKind.DWord)
            regAppAddInKey.SetValue("LOADER", sAssemblyPath, RegistryValueKind.String)
            regAppAddInKey.SetValue("MANAGED", 1, RegistryValueKind.DWord)

SubKeyOK:



        Catch ex As System.Exception
            CMain.DebugException(ex)
            Return
        Finally
            If Not (regAcadAppKey Is Nothing) Then regAcadAppKey.Close()
            If Not (regAcadProdKey Is Nothing) Then regAcadProdKey.Close()
        End Try

    End Sub

    Public Shared Sub UnregisterMyApp()
        '' Get the AutoCAD Applications key
        Dim sProdKey As String = HostApplicationServices.Current.RegistryProductRootKey

        Dim regAcadProdKey As RegistryKey = Registry.CurrentUser.OpenSubKey(sProdKey)
        Dim regAcadAppKey As RegistryKey = regAcadProdKey.OpenSubKey("Applications", True)

        '' Delete the key for the application
        regAcadAppKey.DeleteSubKeyTree(sTHISAPPNAME)
        regAcadAppKey.Close()
    End Sub
#End Region

#Region " --      CUI Creation"

	Private Sub BuildMenuCUI()
        Dim bForceLoad As Boolean = False

		Try
			Dim myCuiFile As String
			Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
			Dim mainCui As String = _
			    Application.GetSystemVariable("MENUNAME").ToString() & ".cui"
			Dim cs As CustomizationSection = New CustomizationSection(mainCui)
			Dim pcfc As PartialCuiFileCollection = cs.PartialCuiFiles
			Dim myCuiSectionName As String = "FieldSK"
			' Get the location of this module
			Dim sAssemblyPath As String = _
			  System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
			myCuiFile = sAssemblyPath & "\Misc\UI.cui"


			If (System.IO.File.Exists(myCuiFile)) Then
				Debug.Print("Customization file <" & myCuiFile & "> exists. Loading...")
			Else
				Debug.Print("Customization file <" & myCuiFile & "> does not exist. Building...")
                bForceLoad = True
                #If HARDCORE_CUI
                    cuiCl = New CCuiF()
                    
                    '// general elements
                    CApp.cuiCl.AddMacro(sCMD_SETTINGS,"")


				    ' allow each command to have it's own CUI elements
				    CM_Grid.DoCUI(Nothing, Nothing)
				    CM_3DPoints.DoCUI(Nothing, Nothing)
				    CM_Dims.DoCUI(Nothing, Nothing)
				    CM_ImageDb.DoCUI(Nothing, Nothing)
				    CM_PolyArea.DoCUI(Nothing, Nothing)
				    CM_Symbols.DoCUI(Nothing, Nothing)
				    CM_Table.DoCUI(Nothing, Nothing)
                CM_Survey1.DoCUI(Nothing, Nothing)
                CM_Polyline.DoCUI(Nothing, Nothing)
#If RO_SPECIFICS = True Then
                CM_RO_Tables.DoCUI(Nothing, Nothing)
#End If

                    cuiCl.Close()
                    cuiCl = Nothing
                #Else
				    ' Create a customization section for our partial menu
				    Dim pcs As CustomizationSection = _
				        New CustomizationSection()
				    pcs.MenuGroupName = myCuiSectionName

				    ' Let's add a menu group, with two commands
				    Dim mg As MacroGroup = _
				        New MacroGroup(myCuiSectionName, pcs.MenuGroup)


                    '// general elements
		            Dim mm1 As MenuMacro = Nothing
		            mm1 = New MenuMacro(mg, sCMD_SETTINGS, _
		                                "^C^C" & sCMD_SETTINGS, _
		                                "ID_" & sCMD_SETTINGS)

				    ' allow each command to have it's own CUI elements
				    CM_Grid.DoCUI(pcs, mg)
				    CM_3DPoints.DoCUI(pcs, mg)
				    CM_Dims.DoCUI(pcs, mg)
				    CM_ImageDb.DoCUI(pcs, mg)
				    CM_PolyArea.DoCUI(pcs, mg)
				    CM_Symbols.DoCUI(pcs, mg)
				    CM_Table.DoCUI(pcs, mg)
                CM_Survey1.DoCUI(pcs, mg)
                CM_Polyline.DoCUI(pcs, mg)
#If RO_SPECIFICS = True Then
                CM_RO_Tables.DoCUI(pcs, mg)
#End If


				    ' Finally we save the file and load it
				    pcs.SaveAs(myCuiFile)
                #End If
			End If

			If (pcfc.Contains(myCuiFile)) Then
                If (bForceLoad = True)  Then
				    Debug.Print("Customization file <" & myCuiFile & "> reloaded")
			        ReLoadMyCui(myCuiFile.Replace("\", "/"))
                Else
				    Debug.Print("Customization file <" & myCuiFile & "> already loaded")
                End If
			Else
				Debug.Print("Customization file <" & myCuiFile & "> not loaded")
				LoadMyCui(myCuiFile.Replace("\", "/"))
			End If


		Catch ex As System.Exception
			CMain.DebugException(ex)
		End Try

	End Sub

	Private Sub LoadMyCui(ByRef cuiFile As String)
		' This load technique sends a LISP string to the
		' command line (which avoid us having to set FILEDIA
		' to 0) after setting CMDECHO to 0, to minimize
		' what's displayed.
		' We make sure the LISP string resets the  value of
		' CMDECHO at the end (the string is executed
		' asynchronously, so we don't have the chance to do
		' it in our calling function).

		Dim doc As Document = Application.DocumentManager.MdiActiveDocument()
		Dim oldCmdEcho As Object = Application.GetSystemVariable("CMDECHO")
		Application.SetSystemVariable("CMDECHO", 0)
		Try
			ads_queueexpr("(command " & QUOTE & "CUILOAD" & QUOTE & " " & QUOTE & _
			cuiFile & QUOTE & ")(setvar " & QUOTE & "CMDECHO" & QUOTE & " " & _
			oldCmdEcho.ToString() & ")(princ) ")
		Catch ex As System.Exception
		End Try
	End Sub

	Private Sub ReLoadMyCui(ByRef cuiFile As String)
		' This load technique sends a LISP string to the
		' command line (which avoid us having to set FILEDIA
		' to 0) after setting CMDECHO to 0, to minimize
		' what's displayed.
		' We make sure the LISP string resets the  value of
		' CMDECHO at the end (the string is executed
		' asynchronously, so we don't have the chance to do
		' it in our calling function).

		Dim doc As Document = Application.DocumentManager.MdiActiveDocument()
		Dim oldCmdEcho As Object = Application.GetSystemVariable("CMDECHO")
		Application.SetSystemVariable("CMDECHO", 0)
		Try
			ads_queueexpr("(command " & QUOTE & "CUIUNLOAD" & QUOTE & " " & QUOTE & _
			    cuiFile & QUOTE & ")(command " & QUOTE & "CUILOAD" & QUOTE & " " & QUOTE & _
			    cuiFile & QUOTE & ")(setvar " & QUOTE & "CMDECHO" & QUOTE & " " & _
			    oldCmdEcho.ToString() & ")(princ) ")
		Catch ex As System.Exception
		End Try
	End Sub

#End Region

#Region "Related to modules"

    '// --------------------------------------------------------------------- '
    Public Shared Function MNameByID (mId As MIDS) As String
        Select Case Mid
            Case    MIDS.GRID:
                Return CM_Grid.GetName()
            Case    MIDS.FSK_PT3D:
                Return CM_3DPoints.GetName()
            Case    MIDS.DIMS:
                Return CM_Dims.GetName()
            Case    MIDS.IMGDB:
                Return CM_ImageDb.GetName()
            Case    MIDS.POLYA:
                Return CM_PolyArea.GetName()
            Case    MIDS.SIMB:
                Return CM_Symbols.GetName()
            Case MIDS.TABLE
                Return CM_Table.GetName()
            Case MIDS.SURV1
                Return CM_Survey1.GetName()
            Case MIDS.POLY
                Return CM_Polyline.GetName()
#If RO_SPECIFICS = True Then
            Case MIDS.RO_TABLE
                Return CM_RO_Tables.GetName()
#End If
        End Select
        Return Nothing
    End Function
    '// ===================================================================== '

    '// --------------------------------------------------------------------- '
    Public Shared Function MIDByName (ByRef sName As String) As MIDS
        Select Case sName.ToUpper()
            Case    CM_Grid.GetName().ToUpper():
                Return MIDS.GRID
            Case    CM_3DPoints.GetName().ToUpper():
                Return MIDS.FSK_PT3D
            Case    CM_Dims.GetName().ToUpper():
                Return MIDS.DIMS
            Case    CM_ImageDb.GetName().ToUpper():
                Return MIDS.IMGDB
            Case    CM_PolyArea.GetName().ToUpper():
                Return MIDS.POLYA
            Case    CM_Symbols.GetName().ToUpper():
                Return MIDS.SIMB
            Case CM_Table.GetName().ToUpper()
                Return MIDS.TABLE
            Case CM_Survey1.GetName().ToUpper()
                Return MIDS.SURV1
            Case CM_PolyArea.GetName().ToUpper()
                Return MIDS.POLY
#If RO_SPECIFICS = True Then
            Case CM_RO_Tables.GetName().ToUpper()
                Return MIDS.RO_TABLE
#End If
        End Select
        Return Nothing
    End Function
    '// ===================================================================== '

    '// --------------------------------------------------------------------- '
    Public Shared Function MLDescrByID (mId As MIDS) As String
        Select Case Mid
            Case    MIDS.GRID:
                Return CM_Grid.GetDescription()
            Case    MIDS.FSK_PT3D:
                Return CM_3DPoints.GetDescription()
            Case    MIDS.DIMS:
                Return CM_Dims.GetDescription()
            Case    MIDS.IMGDB:
                Return CM_ImageDb.GetDescription()
            Case    MIDS.POLYA:
                Return CM_PolyArea.GetDescription()
            Case    MIDS.SIMB:
                Return CM_Symbols.GetDescription()
            Case MIDS.TABLE
                Return CM_Table.GetDescription()
            Case MIDS.SURV1
                Return CM_Survey1.GetDescription()
            Case MIDS.POLY
                Return CM_Polyline.GetDescription()
#If RO_SPECIFICS = True Then
            Case MIDS.RO_TABLE
                Return CM_RO_Tables.GetDescription()
#End If
        End Select
        Return Nothing
    End Function
    '// ===================================================================== '

    '// --------------------------------------------------------------------- '
    Public Shared Function MLDescrByID ( _
        ByVal mId As MIDS, _
        ByRef sName As String, _
        ByRef sVer As String, _
        ByRef sTip As String) As Boolean
        
        Select Case Mid
            Case    MIDS.GRID:
                CM_Grid.GetInfos(sName,sVer,sTip)
                Return TRUE
            Case    MIDS.FSK_PT3D:
                CM_3DPoints.GetInfos(sName,sVer,sTip)
                Return TRUE
            Case    MIDS.DIMS:
                CM_Dims.GetInfos(sName,sVer,sTip)
                Return TRUE
            Case    MIDS.IMGDB:
                CM_ImageDb.GetInfos(sName,sVer,sTip)
                Return TRUE
            Case    MIDS.POLYA:
                CM_PolyArea.GetInfos(sName,sVer,sTip)
                Return TRUE
            Case    MIDS.SIMB:
                CM_Symbols.GetInfos(sName,sVer,sTip)
                Return TRUE
            Case    MIDS.TABLE:
                CM_Table.GetInfos(sName,sVer,sTip)
                Return TRUE
            Case MIDS.SURV1
                CM_Survey1.GetInfos(sName, sVer, sTip)
                Return True
            Case MIDS.TABLE
                CM_Polyline.GetInfos(sName, sVer, sTip)
                Return True
#If RO_SPECIFICS = True Then
            Case MIDS.RO_TABLE
                CM_RO_Tables.GetInfos(sName, sVer, sTip)
                Return True
#End If
        End Select
        Return FALSE
    End Function
    '// ===================================================================== '

#End Region

#Region "ACAD functions"
    Private Declare Auto Function acedPostCommand Lib "acad.exe" _
      Alias "?acedPostCommand@@YAHPB_W@Z" _
      (ByVal strExpr As String) As Integer
    Public Declare Auto Function ads_queueexpr Lib "acad.exe" _
      (ByVal strExpr As String) As Integer
#End Region

#Region "C O M M A N D S"


    '// --------------------------------------------------------------------- '
    '// display settings dialog
    <CommandMethod(sCMD_SETTINGS)> _
    Public Sub Show_Settings()
        Try
            Dim StgD As CD_Mngr = New CD_Mngr
            Application.ShowModalDialog(StgD)
            StgD = Nothing
            GC.Collect()
            GC.WaitForPendingFinalizers()
        Catch ex As System.Exception
            CMain.DebugException(ex)
        End Try
    End Sub
    '// ===================================================================== '


#End Region

End Class ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


'//  CLASS    =============================================================== '
'//
'//
'//
'//
'//  FUNCTIONS    ----------------------------------------------------------- '

'//  FUNCTIONS    =========================================================== '
'//
'//
'//
'//
'// ------------------------------------------------------------------------- '
'// ========================================================================= '
